#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <Dynamics/ExtForce/gravity_cuda.h>
#include <string>
using namespace PhysLeo;
namespace py = pybind11;

template<typename T>
static void declareGravityCpu(py::module &mod, const std::string &typestr)
{
    using class_type = GravityCpu<T>;
    auto pyclass_name = std::string("GravityCpu") + typestr;
    py::class_<class_type, std::shared_ptr<class_type>>cls(mod, pyclass_name.c_str());

    cls.def(py::init());
    cls.def("allocateResource", &class_type::allocateResource);
    cls.def("getGravityAcceleration", &class_type::getGravityAcceleration);
    cls.def("setGravityAcceleration", &class_type::setGravityAcceleration);
    cls.def("addGravityForce", &class_type::addGravityForce);
}

template<typename T>
static void declareGravityCuda(py::module &mod, const std::string &typestr)
{
    using class_type = GravityCuda<T>;
    using base_type = GravityCpu<T>;
    auto pyclass_name = std::string("GravityCuda") + typestr;
    py::class_<class_type, base_type, std::shared_ptr<class_type>>cls(mod, pyclass_name.c_str());

    cls.def(py::init());
    cls.def("addGravityForce", &class_type::addGravityForce);
}

void initGravity(py::module &m)
{
    declareGravityCpu<float>(m, std::string("F"));
    declareGravityCpu<double>(m, std::string("D"));

    declareGravityCuda<float>(m, std::string("F"));
    declareGravityCuda<double>(m, std::string("D"));
}
